a11y: Keep the gail notebook in the notebook page
authorBenjamin Otte <otte@redhat.com>
Wed, 29 Jun 2011 14:17:07 +0000 (16:17 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 5 Jul 2011 20:08:55 +0000 (16:08 -0400)
We used to keep the GtkNotebook, but that causes issues at creation time
of the GailNotebook, when the GtkNotebook does not yet have an
accessible set and so it can't be queried.

gtk/a11y/gailnotebook.c
gtk/a11y/gailnotebookpage.c
gtk/a11y/gailnotebookpage.h

index f00283abf237bd11ef534fbf66f7e0fecd30fecb..dd8a5ca63fb2d4c67cdfb12cb544b679c8f60e67 100644 (file)
@@ -402,7 +402,7 @@ create_notebook_page_accessible (GailNotebook *gail_notebook,
 {
   AtkObject *obj;
 
-  obj = gail_notebook_page_new (notebook, child);
+  obj = gail_notebook_page_new (gail_notebook, child);
   g_hash_table_insert (gail_notebook->pages,
                        child,
                        obj);
index 6b31280449a36601dcc371fe66fc33fc394b0743..b323d1988dc37ea85c46bcd4b1de705a7607f7fe 100644 (file)
@@ -167,20 +167,21 @@ notify_child_added (gpointer data)
 }
 
 AtkObject*
-gail_notebook_page_new (GtkNotebook *notebook, 
-                        GtkWidget   *child)
+gail_notebook_page_new (GailNotebook *notebook, 
+                        GtkWidget    *child)
 {
   GObject *object;
   AtkObject *atk_object;
   GailNotebookPage *page;
   GtkWidget *label;
 
-  g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);
+  g_return_val_if_fail (GAIL_IS_NOTEBOOK (notebook), NULL);
+  g_return_val_if_fail (GTK_WIDGET (child), NULL);
 
   object = g_object_new (GAIL_TYPE_NOTEBOOK_PAGE, NULL);
 
   page = GAIL_NOTEBOOK_PAGE (object);
-  page->notebook = notebook;
+  page->notebook = GTK_ACCESSIBLE (notebook);
   page->child = child;
   page->textutil = NULL;
   
@@ -325,10 +326,7 @@ gail_notebook_page_get_parent (AtkObject *accessible)
   
   page = GAIL_NOTEBOOK_PAGE (accessible);
 
-  if (!page->notebook)
-    return NULL;
-
-  return gtk_widget_get_accessible (GTK_WIDGET (page->notebook));
+  return ATK_OBJECT (page->notebook);
 }
 
 static gint
@@ -352,7 +350,7 @@ gail_notebook_page_ref_child (AtkObject *accessible,
     return NULL;
    
   page = GAIL_NOTEBOOK_PAGE (accessible);
-  if (!page->notebook)
+  if (!page->child)
     return NULL;
 
   child_obj = gtk_widget_get_accessible (page->child);
@@ -366,10 +364,11 @@ gail_notebook_page_get_index_in_parent (AtkObject *accessible)
   GailNotebookPage *page;
 
   page = GAIL_NOTEBOOK_PAGE (accessible);
-  if (!page->notebook || !page->child)
+  if (!page->child)
     return -1;
 
-  return gtk_notebook_page_num (page->notebook, page->child);
+  return gtk_notebook_page_num (GTK_NOTEBOOK (gtk_accessible_get_widget (page->notebook)),
+                                page->child);
 }
 
 static AtkStateSet*
@@ -778,7 +777,7 @@ get_label_from_notebook_page (GailNotebookPage *page)
   GtkWidget *child;
   GtkNotebook *notebook;
 
-  notebook = page->notebook;
+  notebook = GTK_NOTEBOOK (gtk_accessible_get_widget (page->notebook));
   if (!notebook)
     return NULL;
 
index 5f68b5f1af0e45ecef4623dd989090bbb8b2ae37..9c8aba6f7b8c2366b7dd586433539b08a3868fa7 100644 (file)
@@ -39,7 +39,7 @@ struct _GailNotebookPage
 {
   AtkObject parent;
 
-  GtkNotebook *notebook;
+  GtkAccessible *notebook;
   
   GtkWidget *child;
   guint notify_child_added_id;
@@ -54,7 +54,7 @@ struct _GailNotebookPageClass
   AtkObjectClass parent_class;
 };
 
-AtkObject *gail_notebook_page_new(GtkNotebook *notebook, GtkWidget *child);
+AtkObject *gail_notebook_page_new (GailNotebook *notebook, GtkWidget *child);
 
 void       gail_notebook_page_invalidate (GailNotebookPage *page);